#include "Josephus.h"
#include <iostream>
#include <assert.h>


Josephus::Josephus(int _index)
{
	index = _index;
	next = NULL;
}

Josephus* Josephus::count(int _count)
{
	int cnt = 1;
	assert(0 < _count);
	Josephus* node = this ->next;
	while(this != node && cnt <= _count - 1)
	{
		++cnt;
		node = node->next;
	}
	assert(cnt == _count - 1);
	
	if(node == node->next)
		return node;

	return node->next->next;
}